package chalmers.game.subterranean.util;

public class Position {

  public final int depth;
  public final Point point;

  public Position(int depth, int x, int y) {
    this.depth = depth;
    this.point = new Point(x, y);
  }

  @Override
  public boolean equals(Object o) {
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    Position position = (Position) o;

    if (depth != position.depth) {
      return false;
    }
    if (!point.equals(position.point)) {
      return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    int result = depth;
    result = 31 * result + point.hashCode();
    return result;
  }

  public Position(int depth, Point point) {
    this.depth = depth;
    this.point = point;
  }

  @Override
  public String toString() {
    return (this.depth + "." + this.point.toString());
  }

  /**
   * 
   * @author TH
   */
  public static class Point {

    public final int x;
    public final int y;

    public Point(int x, int y) {
      super();
      this.x = x;
      this.y = y;
    }

    @Override
    public String toString() {
      return this.x + "." + this.y;
    }

    @Override
    public boolean equals(Object o) {
      if (o == null || getClass() != o.getClass()) {
        return false;
      }
      Point point = (Point) o;
      if (x != point.x) {
        return false;
      }
      if (y != point.y) {
        return false;
      }
      return true;
    }

    @Override
    public int hashCode() {
      int result = x;
      result = 31 * result + y;
      return result;
    }
  }

}
